package com.example.w2.config;

import javax.xml.ws.Endpoint;

import com.example.w2.service.UserInfoWebService;
import com.example.w2.impl.UserInfoWebServiceImpl;
import org.apache.cxf.Bus;
  import org.apache.cxf.bus.spring.SpringBus;
  import org.apache.cxf.jaxws.EndpointImpl;
  import org.apache.cxf.transport.servlet.CXFServlet;
  import org.springframework.boot.web.servlet.ServletRegistrationBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;



         /**
 17  *
 18  * @author
 19  *
 20  */
         @Configuration
 public class WebServiceConfig {

             @Bean(name = "cxfServlet")  // 注入servlet bean name不能dispatcherServlet ,否则会覆盖dispatcherServlet
     public ServletRegistrationBean<CXFServlet> cxfServlet() {
                return new ServletRegistrationBean<CXFServlet>(new CXFServlet(), "/webservice/*");
                // return new ServletRegistrationBean<CXFServlet>(new CXFServlet(), "/UserInfoWebService");
             }

             @Bean
     public UserInfoWebService userInfoWebService() {
                 return new UserInfoWebServiceImpl();
             }

             @Bean(name = Bus.DEFAULT_BUS_ID)
     public SpringBus springBus() {
                 return new SpringBus();
             }

             @Bean
     public Endpoint endpoint() {
                 // 参数二，是SEI实现类对象
                 EndpointImpl endpoint = new EndpointImpl(this.springBus(), this.userInfoWebService());
                 // 发布服务
                 endpoint.publish("/userListService");
                 return endpoint;
             }

         }
